
class Animal{
    public String name;
    public void eat(){
        System.out.println(name+" 正在吃饭 ");
    }
}
class Dog extends Animal{
    public String color;
    public void wangWang(){
        System.out.println(name+" 汪汪叫");
    }
}

class Bird extends Animal{
    public String wing;
    public void zhaZha(){
        System.out.println(name+" 渣渣叫");
    }
}


public class Test1{
    public static void main(String[] args) {
        Animal animal1=new Dog();
        Dog dog1=(Dog)animal1;
        dog1.name="帅哥";
        dog1.wangWang();
    }
    public static void main1(String[] args) {

        Animal animal=new Dog();  //向上转型
        animal.name="石榴";
        animal.eat();   //animal.wangWang不可以,因为Animal这个类就没有wangWang这个方法

    }
}

